/**
 * @author		Sergey Suzdalskiy
 * @e-mail:		sergey.suzdalskiy@gmail.com
 */
package ua.kiev.gcore.ui.controls
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	public class CheckButton extends ButtonSelect
	{
		private const BUTTON_CHECKED_FRAME:String = "checked";
		
		protected var _checked:Boolean;
//		protected var active:Boolean;
		
		public function CheckButton(UID:String, BackGround:MovieClip, Label:TextField, textValue:String, MouseClickFunction:Function)
		{
			super(UID, BackGround, Label, textValue, MouseClickFunction);	
			Checked = false;
		}
		
		public function set Checked(value:Boolean):void{
			if(_checked != value){
				_checked = value;
				Selected = value;
				if(_checked){
					try{
						(backGround as MovieClip).gotoAndStop(BUTTON_CHECKED_FRAME);
					}catch(error:Error){
						//TODO
					}
				}
				dispatchEvent(new Event(Event.CHANGE));
			}
		}
		public function get Checked():Boolean{
			return _checked;
		}
	}
}